com.cete.dynamicpdf.cryptography
Class Aes128Security



Example: The following example will set the AES security of the document so that the anyone who logs in with the user password will not be able to edit annotations or form fields.

	import com.cete.dynamicpdf.Document;
	import com.cete.dynamicpdf.Font;
	import com.cete.dynamicpdf.Page;
	import com.cete.dynamicpdf.cryptography.Aes128Security;
	import com.cete.dynamicpdf.pageelements.Label;
 
	public class MyClass {
		public static void main(String args[]){
	   
		// Create a PDF Document
		Document document = new Document();

		// Create a Page and add it to the document
		Page page = new Page();
		document.getPages().add(page);

		// Create a AES 128 bit security object
		Aes128Security security = new Aes128Security("owner", "user");

		// Set these properties to make form fields readonly
		security.setAllowFormFilling(false);
		security.setAllowEdit(false);
		security.setAllowUpdateAnnotsAndFields(false);

		// Add the security object to the document
		document.setSecurity(security);

		// Create and display a label as a reference
		String text = "This document has been encrypted with AES 128 bit encryption.";
		page.getElements().add(new Label(text, 50, 50, 400, 100, Font.getHelvetica(), 18));
		
		// Save the PDF
		document.draw("[PhysicalPath]/MyDocument.pdf" );
		}
	}